package com.pension.model.dao;

import java.sql.Connection;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public class ConnectionHelper {

	public static Connection getConnection() {
		try {
			//web.xml에 등록된 connection pool 설정으로부터 
			//Connection pool을 반환하는 코드
			Context initContext = new InitialContext();
			Context envContext  = 
				(Context)initContext.lookup("java:/comp/env");
			DataSource ds = 
				(DataSource)envContext.lookup("jdbc/pension");
			Connection conn = ds.getConnection();
			
			return conn;
			
		} catch (Exception ex) {
			ex.printStackTrace();
			return null;
		}
	}
	
}








